import request from '@/utils/request.js';
import {download, toFormData} from '@/utils/common.js';


/**
 * 分页查询学生推荐表信息
 */
export async function pageList(params) {
  const res = await request.get('/counsellor/student/recommend/list', {params});
  if (res.data.code === 200) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


/**
 * 查询学生推荐表信息
 * @returns {Promise<any>}
 */
export async function selectStudentRecommendInfo(code) {
  const res = await request.get('/counsellor/student/recommend/info/' + code);
  if (res.data.code === 200) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 更新指定学生的辅导员审核信息
 * @param code
 * @param status
 * @returns {Promise<*>}
 */
export async function updateStudentRecommendCheck(code, status) {
  const res = await request.put('/counsellor/student/recommend/updateCheck', {
    code,
    status
  });
  if (res.data.code === 200) {
    return res.data.msg;
  }
  return Promise.reject(new Error(res.data.msg));
}


/**
 * 修改学生的所在系意见
 * @param code
 * @param departmentOpinion
 * @returns {Promise<*>}
 */
export async function fillStudentRecommendDepartmentOpinion(code, opinion) {
  const res = await request.put('/counsellor/student/recommend/fillOpinion', {
    code,
    opinion
  });
  if (res.data.code === 200) {
    return res.data.msg;
  }
  return Promise.reject(new Error(res.data.msg));
}


export async function fillStudentRecommendDepartmentOpinionAndCheck(code, opinion) {
  const res = await request.put('/counsellor/student/recommend/fillOpinion/check', {
    code,
    opinion
  });
  if (res.data.code === 200) {
    return res.data.msg;
  }
  return Promise.reject(new Error(res.data.msg));
}
